var express = require('express');
var router = express.Router();
var query = require('./Database');
/* GET home page. */
router.get('/', function(req, res, next) {
    res.render('Prohuangbang2', {});
});
router.post('/check',async (req,res)=>{
    console.log("--------------");
    console.log(req.body);
    let list = req.body;
    let rows = await query("select * from users where phone = "+list.phone);
    if (rows.length>0){
        let data = {code:0};
        res.send(data);
    }else {
        let data = {code:200};
        res.send(data);
    }
});
router.post('/changephone',async (req,res)=>{
    console.log("--------------");
    console.log(req.body);
    let list = req.body;
    await query("update users set phone = "+list.phone+" where id = "+list.userid);
    let data = {code:100};
    res.send(data);
});
module.exports = router;